import React from 'react'

export default class Son extends React.Component{
    constructor(props){
        super(props)

        this.state={
            ...this.props.store.getState()
        }
    }
    componentDidMount(){
        this.props.store.subscribe(()=>{
            this.setState({
                ...this.props.store.getState()
            })
        })
    }
    render(){
        let {msg,num}=this.state
        return <div>
           <p>--------后代组件----------</p>
            <p>redux中的数据：：-----》<span style={{color:'#f0f'}}>{msg}</span></p>
            <p>改变了数据》》》》<span style={{color:'#f0f'}}>{num}</span></p>
            <button onClick={ev=>{this.props.store.dispatch({type:'m'})}}>改变msg</button>
        </div>
    }
}